<meta charset="utf-8">
<title>平台挂卖</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="网站描述">
<meta name="keywords" content="">
<meta name="author" content="wangl">
<link rel="icon" href="http://ow9lg82yy.bkt.clouddn.com/24f5c360-485d-4a6d-9468-2a61c353cf37.ico">
<link rel="stylesheet" href="/static/layui/css/layui.css" media="all">
<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all">
<link rel="stylesheet" href="/static/css/user.css" media="all">
<link rel="stylesheet" href="/static/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">


</head>
<body class="childrenBody">
<div class="layui-col-xs12">
    <fieldset class="layui-elem-field">
        <legend>挂卖检索</legend>
        <div class="layui-field-box">
            <form class="layui-form" id="searchForm" action="">
                <div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>挂卖数量区间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="lowAliveCount" id="lowAliveCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                        <span>-</span>
                        <div class="layui-input-inline">
                            <input type="text" name="highAliveCount" id="highAliveCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="2">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>已交易数量区间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="lowDealtCount" id="lowDealtCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                        <span>-</span>
                        <div class="layui-input-inline">
                            <input type="text" name="highDealtCount" id="highDealtCount" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="2">
                        </div>
                    </div>
                    <div class="layui-inline" style="margin-left: 15px">
                        <label>发布时间:</label>
                        <div class="layui-input-inline">
                            <input type="text" name="lowDate1" id="lowDate1" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="1">
                        </div>
                        <span>-</span>
                        <div class="layui-input-inline">
                            <input type="text" name="highDate1" id="highDate1" lay-verify="date"
                                   autocomplete="off" class="layui-input" lay-key="2">
                        </div>
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>卖方姓名:</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" id="realName" name="realName" placeholder="请输入标题"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline" style="margin-left: 15px">
                    <label>手机号:</label>
                    <div class="layui-input-inline">
                        <input type="text" value="" id="phoneNum" name="phoneNum" placeholder="请输入内容"
                               class="layui-input search_input">
                    </div>
                </div>
                <div class="layui-inline">
                    <button type="button" class="layui-btn" onclick="getHangSale()">搜索</button>
                </div>
                <div class="layui-inline">
                    <#--<button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
                </div>
            </form>
        </div>
    </fieldset>
    <div class="layui-form users_list">

                        <#--class="layui-table-header"-->
                        <table cellspacing="0" cellpadding="0" border="0" class="layui-table">
                            <thead>
                            <tr>

                                <th data-field="pageId">
                                    <div class="layui-table-cell laytable-cell-1-pageId"><span>编号</span></div>
                                </th>
                                <th data-field="hangSaleId">
                                    <div class="layui-table-cell laytable-cell-1-hangSaleId"><span>挂卖单号</span></div>
                                </th>
                                <th data-field="hangSaleUser">
                                    <div class="layui-table-cell laytable-cell-1-hangSaleUser"><span>挂卖人</span></div>
                                </th>
                                <th data-field="phoneNum">
                                    <div class="layui-table-cell laytable-cell-1-phoneNum"><span>手机号</span></div>
                                </th>
                                <#--列表显示：编号、挂卖单号、挂卖人、手机号、挂卖数量、挂卖单价、已交易数量、挂卖单状态、发布时间、操作-->
                                <th data-field="coinType">
                                    <div class="layui-table-cell laytable-cell-1-coinType"><span>币种</span></div>
                                </th>
                                <th data-field="hangSaleNum">
                                    <div class="layui-table-cell laytable-cell-1-hangSaleNum"><span>挂卖数量</span></div>
                                </th>
                                <th data-field="hangSalePrice">
                                    <div class="layui-table-cell laytable-cell-1-hangSalePrice"><span>挂卖单价</span></div>
                                </th>
                                <th data-field="hangSaleDealNum">
                                    <div class="layui-table-cell laytable-cell-1-hangSaleDealNum"><span>已交易数量</span>
                                    </div>
                                </th>
                                <th data-field="hangSaleState">
                                    <div class="layui-table-cell laytable-cell-1-hangSaleState"><span>挂卖单状态</span></div>
                                </th>
                                <th data-field="publistTime" data-unresize="true">
                                    <div class="layui-table-cell laytable-cell-1-publistTime"><span>发布时间</span></div>
                                </th>
                                <th data-field="9">
                                    <div class="layui-table-cell laytable-cell-1-9" align="center"><span>操作</span></div>
                                </th>
                            </tr>
                            </thead>
                            <tbody id="hangSaleList">
                            </tbody>
                        </table>
                        <div id="main" style="width: 100% ;height: 100%"></div>
                        <div class="box-tools pull-right">
                            <ul class="pagination" id="pagination_ul">
                            </ul>
                        </div>

    </div>
</div>
</body>
<script type="text/javascript" src="/static/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript" src="/static/js/tools.js"></script>
<script type="text/javascript" src="/static/zTree/v3/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="/static/js/CodeConst.js"></script>
<!-- <#--<script type="text/javascript" src="/static/js/jquery-1.10.2.js"></script>--> -->
<script type="text/javascript" src="/static/js/common.js"></script>
<script>


    //获取数据


    var baseDto = getHangSale();

    function loadData(baseDto) {
        if (baseDto.code == ERROR)
            console.log(baseDto.msg);
        else {
            //数据

            var data = baseDto.data.list;
            var text = "";
            var operate = "";
            var del = "";
            $.each(data, function (index, hangSale) {

                if (hangSale.stateNum == "1") {
                    del = "<button type='button' onclick='getDel(" + hangSale.hangSaleId + ")'     class=\"layui-btn layui-btn-xs\">撤单</button>\n";
                } else {
                    del = "";
                }

                if (hangSale.hangSaleDealNum != 0) {
                    operate = "<a href='/back/order/hangSale/detailpage?hangSaleId=" + hangSale.hangSaleId + "'  type=\"button\" class=\"layui-btn layui-btn-xs\">查看记录</a>\n";
                }else {
                    operate = "";
                }
                text += "<tr>\n" +
                    "<td>" + (index + 1) + "</td>\n" +
                    "<td id='hangSaleId" + hangSale.hangSaleId + "'>" + hangSale.hangSaleId + "</td>\n" +
                    "<td>" + hangSale.hangSaleUser + "</td>\n" +
                    "<td>" + hangSale.phoneNum + "</td>\n" +
                    "<td>" + hangSale.coinType + "</td>\n" +
                    "<td>" + hangSale.hangSaleNum + "</td>\n" +
                    "<td>" + hangSale.hangSalePrice + "</td>\n" +
                    "<td>" + hangSale.hangSaleDealNum + "</td>\n" +
                    "<td>" + hangSale.hangSaleState + "</td>\n" +
                    "<td>" + hangSale.publistTime + "</td>\n" +
                    "<td class=\"text-center\" align=\"center\">\n" +
                    operate + del
                "</td>\n" +
                "</tr>";
            });
            var hangSaleListDom = $("#hangSaleList");
            hangSaleListDom.empty();//清空子元素
            hangSaleListDom.append($(text));
            var pages = baseDto.data.pages;
            var pageNum = baseDto.data.pageNum;
            var btnList = "";
            btnList += "<li class='first_page'><a onclick='loadPage(this)' link='/back/order/hangSale/list'>" + "首页" + "</a></li>";
            var temp = "<li class='prepage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (pageNum - 1) + "'>上一页</a></li>";
            btnList += temp;
            for (var i = 0; i < pages; i++) {
                btnList += ("<li class='prepage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (i + 1) + "'>" + (i + 1) + "</a></li>\n")
            }
            btnList += ("<li class='nextpage'><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + (pageNum + 1) + "'>下一页</a></li>\n" +
                "<li class='last_page' ><a onclick='loadPage(this)' link='/back/order/hangSale/list?pageNum=" + pages + "'>末页</a></li>");
            var pagination_ul = $("#pagination_ul");
            pagination_ul.empty();
            pagination_ul.append(btnList);
        }
    }


    // function loadPage(a) {
    //     var a_jquery = $(a);
    //     var url = a_jquery.attr("link");
    //     $.ajax(
    //         {
    //             url: url,
    //             type: "GET",
    //             success: function (baseDto) {
    //                 loadData(baseDto);
    //             }
    //         }
    //     );
    // }


    $.ajax({
        url: "/back/order/hangSale/search",
        type: "GET",
        success: function (baseDto) {
            loadData(baseDto);
        }
    });

    function getDel(hangSaleId) {
        console.log(hangSaleId);
        $.ajax({
            url: "/back/order/hangSale/del",
            type: "GET",
            data: {
                hangSaleId: hangSaleId
            },

            success: function (baseDto) {
                location.reload();
            }
        });
    }

    function getHangSale() {
        var lowAliveCount = $("#lowAliveCount").val();
        var highAliveCount = $("#highAliveCount").val();
        var lowDealtCount = $("#lowDealtCount").val();
        var highDealtCount = $("#highDealtCount").val();
        var lowDate1 = $("#lowDate1").val();
        var highDate1 = $("#highDate1").val();
        var realName = $("#realName").val();
        var phoneNum = $("#phoneNum").val();

        $.ajax({
            url: "/back/order/hangSale/search",
            type: "GET",
            data: {
                lowAliveCount: lowAliveCount,
                highAliveCount: highAliveCount,
                lowDealtCount: lowDealtCount,
                highDealtCount: highDealtCount,
                lowDate1: lowDate1,
                highDate1: highDate1,
                realName: realName,
                phoneNum: phoneNum
            },
            success: function (baseDto) {
                loadData(baseDto);
            }
        });
        return baseDto;
    };
</script>
